#include<bits/stdc++.h>
using namespace std;
//#define ll long long
const int N=1e5+2;
struct node{
    int dir=0,v1=0,ac=0;
}car[N];
int limitdir[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t,count1=0;
    cin>>t;
    for(int ii=1;ii<=t;++ii){
        int num,m,length,v;
        cin>>num>>m>>length>>v;
        for(int i=1;i<=num;++i)cin>>car[i].dir>>car[i].v1>>car[i].ac;
        for(int j=1;j<=m;++j)cin>>limitdir[j];
        sort(limitdir+1,limitdir+1+m);
        for(int i=1;i<=num;++i){
            if(car[i].ac==0&&car[i].v1<=v) {
                count1++;
                continue;
            }
            else if(car[i].dir>limitdir[m]){
                count1++;
                continue;
            }
            else if(car[i].ac>0){
                int vv=0;
                vv=sqrt(2*car[i].ac*car[i].dir+pow(car[i].v1,2));
                if(vv<=v) {
                    count1++;
                    continue;
                }
            }
        }
        cout<<count1/2+1<<" ";
        cout<<count1/2+1<<" ";
    }
    return 0;
}
